1. Field of the Invention
The present invention relates to a lens effect method, and particularly to a lens effect method that speeds up the effect process and performs anti-aliasing using transform mask.
2. Description of the Related Art
Lens effect is an application based on the optical refraction axiom. Lens effect refracts a realistic pixel seen to a reference pixel actually on the image surface, and employs the pixels adjacent to the reference pixel to achieve anti-aliasing on the realistic pixel.
In the technical domain of image processing or animation, lens effect is a basic image effect. In the current process method of lens effect, a system has to calculate each of the pixels covered by a virtual lens in real time according to a transform formula corresponding to the virtual lens to find out the corresponding reference pixels on the image surface.
In addition, after finding out the corresponding reference pixels, the system also needs to calculate the influence of adjacent pixels on the reference pixel in this realistic pixel, and then achieve anti-aliasing according to the influence. However, the system requires a great deal of processing power to handle such a real-time calculation, and if the power is not sufficient a halt of the image process or a non-continuous play of the animation results.
It is therefore an object of the present invention to provide a lens effect method that speeds up the entire effect process and performs anti-aliasing to alleviate the alias in realistic pixels using transform mask.
To achieve the above object, the present invention provides a method of performing a lens effect to determine a realistic pixel content of a realistic pixel transformed by a virtual lens having a plurality of points from a plurality of image pixels, the realistic pixel corresponding to a pixel point of the points of the virtual lens.
First, an offset mask having an offset value corresponding to the pixel point is provided and a plurality of weight masks respectively corresponding to the image pixels are also provided, each of the weight masks having a weight value corresponding to the pixel point;
Then, a reference pixel position is calculated by adding a realistic pixel position of the realistic pixel with the offset value corresponding to the pixel point in the offset mask, and one of the image pixels with a position equal to the reference pixel position is selected as a reference pixel.
Then, a weighted process is performed on the addition of an adjacent pixel content of an adjacent pixel adjacent to the reference pixel and a reference pixel content of the reference pixel according to the weight value corresponding to the pixel point in a first weight mask of the weight masks, thereby acquiring the realistic pixel content of the realistic pixel.
Finally, the realistic pixel is displayed according to the realistic pixel content.
According to a first embodiment of the present invention, the first weight mask corresponds to the adjacent pixel, and according to a second embodiment of the present invention, the first weight mask corresponds to the reference pixel.
According to the embodiments, the offset mask may be composed of a horizontal mask and a vertical mask. The horizontal mask stores horizontal offset values on the horizontal direction and the vertical mask stores vertical offset values on the vertical direction. In addition, the realistic pixel content, adjacent pixel content, and the reference pixel content include a RGB value (signal).